<style scoped>
    .inquiry-list-page{}

</style>
<template> 
    <div class="inquiry-list-page">
        <el-form :inline="true" :model="formInline" class="demo-form-inline" style="border-bottom:1px solid #ccc;">
            <el-form-item label="被委托人账号" class="selectMB10">
                <el-input size="mini" v-model="formInline.commissionedAccount" placeholder="请输入被委托人账号"></el-input>
            </el-form-item>
            <el-form-item label="开始日期" prop="startTime" class="selectMB10">
                <el-date-picker type="datetime" size="mini" :editable="false" v-model="formInline.startTime"  placeholder="选择日期" class="selectMB10" prop="startTime" @change="selectedStartTime"></el-date-picker>
            </el-form-item>
            <el-form-item label="结束日期" prop="endTime" class="selectMB10">
                <el-date-picker type="datetime" size="mini" :editable="false" v-model="formInline.endTime"  placeholder="选择日期" class="selectMB10" prop="endTime" @change="selectedEndTime"></el-date-picker>
            </el-form-item>
            <el-form-item label="创建日期" prop="endTime" class="selectMB10">
                <el-date-picker type="date" size="mini" :editable="false" v-model="formInline.createTime" placeholder="选择日期" class="selectMB10" prop="endTime" @change="selectedCreateTime"></el-date-picker>
            </el-form-item>
             <el-form-item label="状态" class="selectMB10">
                <el-select size="mini" clearable v-model="formInline.status" placeholder="请选择" >
                    <el-option v-for="(status,index) in selStatusDropDown['delegation.delegationStatus']" :key="index" :label="status.label" :value="status.value"></el-option>
                </el-select>
            </el-form-item>
            <el-form-item class="selectMB10">
                <el-button class="bolder outsideBtnBS selectAll" :disabled="selectDisabled" size="mini" type="danger" @click="queryDeleSheet()">查询</el-button>
            </el-form-item>
        </el-form>
        <!--权限委托明细-->
        <label class="default-label">权限委托明细</label>
        <!--新增按钮-->
        <el-button class="bolder outsideBtnBS" size="mini" type="danger" @click="createNew()">新增</el-button>
        <!--表格-->
        <el-table :data="DelegationData" border style="width: 100%;" v-loading.body="loading" element-loading-text="拼命加载中">
            <el-table-column type="index" header-align="center" align="center" label="序"  width="40"></el-table-column>
            <el-table-column label="操作" header-align="center" align="center" width="150">
                <template scope="scope">
                    <button class="operationItem bolder disabled" v-if="scope.row.status==0">修改</button>
                    <button class="operationItem bolder" @click="handleUpdateDele(scope.$index,scope.row)" v-else>修改</button>
                    <button class="operationItem bolder disabled" v-if="scope.row.status==0">失效</button>
                    <button class="operationItem bolder" @click="handleLoseDele(scope.$index,scope.row)" v-else :disabled="loseDeleDisabled">失效</button>
                    <button class="operationItem bolder" @click="checkDele(scope.$index,scope.row)">查看</button>
                </template>
            </el-table-column>
            <el-table-column prop="delegationAccount" label="委托人账号" header-align="center" width="100" show-overflow-tooltip></el-table-column>
            <el-table-column prop="delegationUserName" label="委托人姓名" header-align="center" width="100" show-overflow-tooltip></el-table-column>
            <el-table-column prop="startTime" label="委托开始日期" header-align="center" show-overflow-tooltip></el-table-column>
            <el-table-column prop="endTime" label="委托结束日期" header-align="center" show-overflow-tooltip></el-table-column>
            <el-table-column prop="createTime" label="创建日期" header-align="center" width="100" show-overflow-tooltip></el-table-column>
            <el-table-column prop="statusName" label="状态" header-align="center" align="center" width="80" show-overflow-tooltip></el-table-column>
            <!--<el-table-column prop="details" label="委托明细" header-align="center" width="120"></el-table-column>-->
            <el-table-column prop="reason" label="委托事由" header-align="center" show-overflow-tooltip></el-table-column>
        </el-table>
        <!--分页-->
        <el-pagination v-if="isPaging" @size-change="handleSizeChange" @current-change="handleCurrentChange" :current-page="pageIndex"  :page-size="pageSize" layout="total, sizes, prev, pager, next, jumper" :page-count="totalPage" :total="totalNumber"></el-pagination>
        <!--新建-->
        <el-dialog title="新增权限委托" :visible.sync="dialogForm1Visible" :lock-scroll="false">
            <el-form :inline="true" :model="addDeleData" class="demo-form-inline" style="margin-bottom:20px;border-bottom:1px solid #ccc;" ref="addDeleData">
                <el-form-item label="委托人姓名" class="selectMB10" prop="delegationUserName">
                    <el-input  v-model="addDeleData.delegationUserName" disabled></el-input>
                </el-form-item>
                <el-form-item label="委托人账号" class="selectMB10" prop="delegationAccount">
                    <el-input  v-model="addDeleData.delegationAccount" disabled></el-input>
                </el-form-item>
                <el-form-item label="创建日期" class="selectMB10" prop="createTime">
                    <el-input  v-model="addDeleData.createTime" disabled></el-input>
                </el-form-item>
                <el-form-item label="法人名称" class="selectMB10" v-if="isLocal">
                    <el-select size="mini" clearable  v-model="addDeleData.legalPersonName" placeholder="请选择" @change="changeLegalPerson">
                        <el-option v-for="(legalPerson,index) in legalPersonList" :key="index" :label="legalPerson.legalPersonName" :value="legalPerson.id">
                        </el-option>
                    </el-select>
                </el-form-item>
                <el-form-item label="委托开始日期" prop="startTime" :rules="[{ required: true, message: '委托开始日期不能为空'}]">
                    <el-date-picker type="datetime" size="mini" :editable="false" v-model="addDeleData.startTime"  placeholder="选择日期时间" class="selectMB10" prop="startTime" @change="selectedNewStartTime"></el-date-picker>
                </el-form-item>
                <el-form-item label="委托结束日期" prop="endTime" :rules="[{ required: true, message: '委托结束日期不能为空'}]">
                    <el-date-picker type="datetime" size="mini" :editable="false" v-model="addDeleData.endTime"  placeholder="选择日期时间" class="selectMB10" prop="endTime"  @change="selectedNewEndTime"></el-date-picker>
                </el-form-item>
                <el-form-item label="委托事由 " class="selectMB10" prop="reason" :rules="[{ required: true, message: '请填写委托事由'}]" width="300">
                    <el-input  v-model.trim="addDeleData.reason"  placeholder="选择输入委托事由"></el-input>
                </el-form-item>
            </el-form>
            <el-button class="bolder outsideBtnBS" size="mini" type="danger" @click="addDeleSheet()">增加</el-button>
            <el-table :data="deleNewList" border style="width: 100%;margin-top:16px;">
                <el-table-column type="index" header-align="center" align="center" label="序"  width="40"></el-table-column>
                <el-table-column  label="委托单据" header-align="center" show-overflow-tooltip>
                    <template scope="scope">
                        <el-select size="mini" clearable  v-model="scope.row.type" placeholder="请选择">
                            <el-option v-for="(deleType,index) in delegationType" :key="index" :label="deleType.label" :value="deleType.value">
                            </el-option>
                        </el-select>
                    </template>
                </el-table-column>
                <el-table-column  label="被委托人员" header-align="center" show-overflow-tooltip>
                    <template scope="scope">
                        <el-select size="mini" clearable  v-model="scope.row.commissionedUserId" placeholder="请选择" @change="changeDeleAccount(scope.$index,scope.row)">
                            <el-option v-for="(deleUser,index) in deledUserList" :key="index" :label="deleUser.personName" :value="deleUser.id">
                            </el-option>
                        </el-select>
                    </template>
                </el-table-column>
                <el-table-column  label="被委托人员账号" header-align="center" prop="commissionedAccount" show-overflow-tooltip></el-table-column>
            </el-table>
            <div style="margin-top:16px;padding-left:38%;">
                <el-button class="bolder outsideBtnBS" size="mini" type="danger" @click="saveDeleSheet('addDeleData')" :disabled="addSaveDisabled">保存</el-button>
                <el-button class="bolder outsideBtnBS" size="mini" type="danger" @click="cancelDeleSheet()">取消</el-button>
            </div>

        </el-dialog>
        <!--修改-->
        <el-dialog title="修改权限委托" :visible.sync="dialogForm2Visible" :lock-scroll="false">
            <el-form :inline="true" :model="updateDeleData" class="demo-form-inline" style="margin-bottom:20px;border-bottom:1px solid #ccc;" ref="updateDeleData">
                <el-form-item label="委托人姓名" class="selectMB10" prop="delegationUserName">
                    <el-input  v-model="updateDeleData.delegationUserName" disabled></el-input>
                </el-form-item>
                <el-form-item label="委托人账号" class="selectMB10" prop="delegationAccount">
                    <el-input  v-model="updateDeleData.delegationAccount" disabled></el-input>
                </el-form-item>
                <el-form-item label="创建日期" class="selectMB10" prop="createTime">
                    <el-input  v-model="updateDeleData.createTime" disabled></el-input>
                </el-form-item>
                <el-form-item label="法人名称" class="selectMB10" v-if="isLocal">
                    <el-input  v-model="updateDeleData.legalPersonName" disabled></el-input>
                </el-form-item>
                <el-form-item label="委托开始日期" prop="startTime" :rules="[{ required: true, message: '委托开始日期不能为空'}]">
                    <el-date-picker type="datetime" size="mini" :editable="false" v-model.trim="updateDeleData.startTime"  placeholder="选择日期" class="selectMB10" prop="startTime" @change="selectedUpdateStartTime"></el-date-picker>
                </el-form-item>
                <el-form-item label="委托结束日期" prop="endTime" :rules="[{ required: true, message: '委托结束日期不能为空'}]">
                    <el-date-picker type="datetime" size="mini" :editable="false" v-model.trim="updateDeleData.endTime"  placeholder="选择日期" class="selectMB10" prop="endTime"  @change="selectedUpdateEndTime"></el-date-picker>
                </el-form-item>
                <el-form-item label="委托事由： " class="selectMB10" prop="reason" width="300">
                    <el-input  v-model="updateDeleData.reason" disabled></el-input>
                </el-form-item>
            </el-form>
            <label class="default-label">委托明细</label>
            <el-table :data="deleNewList" border style="width: 100%;margin-top:16px;">
                <el-table-column type="index" header-align="center" align="center" label="序"  width="40"></el-table-column>
                <el-table-column  label="委托单据" header-align="center" prop="typeName" show-overflow-tooltip></el-table-column>
                <el-table-column  label="被委托人员" header-align="center" prop="commissionedUserName" show-overflow-tooltip></el-table-column>
                <el-table-column  label="被委托人员账号" header-align="center" prop="commissionedAccount" show-overflow-tooltip></el-table-column>
            </el-table>
            <div style="margin-top:16px;padding-left:38%;">
                <el-button class="bolder outsideBtnBS" size="mini" type="danger" @click="saveUpdateDeleSheet('updateDeleData')" :disabled="updateSaveDisabled">保存</el-button>
                <el-button class="bolder outsideBtnBS" size="mini" type="danger" @click="cancelUpdateDeleSheet()">取消</el-button>
            </div>

        </el-dialog>
        <!--查看弹窗-->
        <el-dialog title="查看权限委托" :visible.sync="dialogForm3Visible" :lock-scroll="false">
            <label class="default-label">委托明细</label>
            <el-table :data="deleNewList" border style="width: 100%;margin-top:16px;">
                <el-table-column type="index" header-align="center" align="center" label="序"  width="40"></el-table-column>
                <el-table-column  label="委托单据" header-align="center" prop="typeName" show-overflow-tooltip></el-table-column>
                <el-table-column  label="被委托人员" header-align="center" prop="commissionedUserName" show-overflow-tooltip></el-table-column>
                <el-table-column  label="被委托人员账号" header-align="center" prop="commissionedAccount" show-overflow-tooltip></el-table-column>
            </el-table>
        </el-dialog>
    </div>
</template>

<script>
       export default {
        data() {
            return {
                nowLangue:{},
                // 查询表单
                formInline:{
                    commissionedAccount:"",//被委托人帐号
                    status:"",//状态
                    createTime:"",//创建日期
                    startTime:"",//开始日期
                    endTime:""//结束日期
                },
                addDeleData:{
                    delegationUserName:"",
                    delegationAccount:"",
                    createTime:"",//创建日期
                    startTime:"",//开始日期
                    endTime:"",//结束日期
                    reason:"",//委托事由
                    legalPersonName:"",//法人名称
                    legalPersonCode:"",//法人编码
                    legalPersonId:""//法人ID
                },
                updateDeleData:{
                    delegationUserName:"",
                    delegationAccount:"",
                    createTime:"",//创建日期
                    startTime:"",//开始日期
                    endTime:"",//结束日期
                    reason:"",//委托事由
                    legalPersonName:"",//法人名称
                    legalPersonCode:"",//法人编码
                    legalPersonId:""//法人ID
                },
                loading:false,
                disabled:false,
                isLocal:false,//根据登录人是否是本部人员判断有无法人

                selStatusDropDown:[],//状态下拉
                DelegationData:[],//查询页面委托明细列表
                delegationType:[],//委托单据下拉
                deledUserList:[],//被委托人列表
                legalPersonList:[],//法人列表
                deleNewList:[],//新建行项目列表

                idParm:"",//修改保存需传的ID值
                //弹窗
                dialogForm1Visible:false,
                dialogForm2Visible:false,
                dialogForm3Visible:false,
                // 分页
                isPaging:false,
                pageIndex:1,    //当前页（必传）
                pageSize :10,   //每页多少条
                totalNumber: 20,
                totalPage:2,
                selectDisabled:false,   //查询禁用
                loseDeleDisabled:false,  //失效操作按钮禁用
                addSaveDisabled:false,    // 新增的保存操作按钮禁用
                updateSaveDisabled:false  // 修改的保存操作按钮禁用
            };
        },
        created:function(){
            var _this=this;
            _this.languageType=="zh"?_this.nowLangue=_this.language.zh:_this.nowLangue=_this.language.en;
        },
        computed:{
            // powerData(){
            //     return this.$store.state.powerData;
            // },
            languageType(){
                return this.$store.state.languageType;
            }
        },
        watch:{
            languageType(){
                var _this=this;
                _this.languageType=="zh"?_this.nowLangue=_this.language.zh:_this.nowLangue=_this.language.en;
            }
        },
       //进入页面立即运行此方法
       mounted: function () {
            var _this = this;
        //    //ajax前后查询按钮禁用
        //    $(".selectAll").ajaxStart(function(){
        //        _this.selectDisabled=true;
        //    });
        //    $(".selectAll").ajaxStop(function(){
        //        _this.selectDisabled=false;
        //    });
            _this.selectStatusDropDown();//状态下拉
            _this.queryDeleSheet();    //表单查询
       },
        methods: {
            //开始日期
            selectedStartTime(val){
                var _this=this;
                _this.formInline.startTime = val;
                if(_this.formInline.endTime && val > _this.formInline.endTime){
                     var err=_this.languageType=="zh"?'开始日期不能大于结束日期':'The start date must not be greater than the end date';
                    _this.common.errorTip(err);
                    _this.formInline.startTime = "";
                };
            },
            // 结束日期
            selectedEndTime(val){
                var _this=this;
                _this.formInline.endTime = val;
                if(_this.formInline.startTime && val < _this.formInline.startTime){
                    var err=_this.languageType=="zh"?'结束日期不能小于开始日期':'The end date must not be less than the start date';
                    _this.common.errorTip(err);
                    _this.formInline.endTime = "";
                };
            },
            selectedCreateTime(val){
                var _this=this;
                _this.formInline.createTime = val;
            },
            //新建开始日期
            selectedNewStartTime(val){
                var _this=this;
                _this.addDeleData.startTime = val;
                if(_this.addDeleData.endTime && val > _this.addDeleData.endTime){
                    var err=_this.languageType=="zh"?'开始日期不能大于结束日期':'The start date must not be greater than the end date';
                    _this.common.errorTip(err);
                    _this.addDeleData.startTime = "";
                };
            },
            // 新建结束日期
            selectedNewEndTime(val){
                var _this=this;
                _this.addDeleData.endTime = val;
                if(_this.addDeleData.startTime && val < _this.addDeleData.startTime){
                    var err=_this.languageType=="zh"?'结束日期不能小于开始日期':'The end date must not be less than the start date';
                    _this.common.errorTip(err);
                    _this.addDeleData.endTime = "";
                };
            },

            //修改开始日期
            selectedUpdateStartTime(val){
                var _this=this;
                _this.updateDeleData.startTime = val;
                if(_this.updateDeleData.endTime && val > _this.updateDeleData.endTime){
                     var err=_this.languageType=="zh"?'开始日期不能大于结束日期':'The start date must not be greater than the end date';
                    _this.common.errorTip(err);
                    _this.updateDeleData.startTime = "";
                };
            },
            // 修改结束日期
            selectedUpdateEndTime(val){
                var _this=this;
                _this.updateDeleData.endTime = val;
                if(_this.updateDeleData.startTime && val < _this.updateDeleData.startTime){
                    var err=_this.languageType=="zh"?'结束日期不能小于开始日期':'The end date must not be less than the start date';
                    _this.common.errorTip(err);
                    _this.updateDeleData.endTime = "";
                };
            },
            //下拉状态
            selectStatusDropDown(){
                var _this = this;
                var tmp=["delegation.delegationStatus"];
                $.ajax({
                    type:'POST',
                    url:_this.metadata_service+"metadata/getPullDownList",
                    cache:false,
                    data:JSON.stringify(tmp),
                    dataType:'JSON',
                    contentType:"application/json;charset=utf-8",
                    success:function(data){
                        if(data.success){
                            _this.selStatusDropDown = data.data;
                        }else{
                            _this.common.errorTip(data.errorMessage);
                        }
                    }
                })
            },
            //权限委托明细查询
            queryDeleSheet(){
                var _this=this;
                _this.loading=true;
                var tmp={
                    commissionedAccount:_this.formInline.commissionedAccount, //被委托人
                    status:_this.formInline.status,//状态
                    createTime:_this.formInline.createTime,//创建日期
                    startTime:_this.formInline.startTime,//开始日期
                    endTime:_this.formInline.endTime,//结束日期
                    pageIndex:_this.pageIndex,
                    pageSize:_this.pageSize
                };
                _this.selectDisabled=true;
                $.ajax({
                    type: 'POST',
                    url: _this.metadata_service+"authorityDelegation/queryPage",
                    cache: false,
                    data:JSON.stringify(tmp),
                    dataType:'JSON',
                    contentType: "application/json;charset=utf-8",
                    success: function (data) {
                        if (data.success) {
                            _this.loading=false;
                            _this.isPaging=true;
                            _this.totalPage=data.data.totalPage;
                            _this.totalNumber=data.data.totalNumber;
                            _this.DelegationData=data.data.dataList;
                        }else{
                            _this.common.errorTip(data.errorMessage)
                        }
                        _this.selectDisabled=false;
                    }
                });
            },
            //新建
            createNew(){
                var _this=this;
                _this.deleNewList=[];
                _this.dialogForm1Visible=true;
                $.ajax({
                    type:'GET',
                    url:_this.metadata_service+"authorityDelegation/saveInitParameter",
                    cache:false,
                    dataType:'JSON',
                    contentType:"application/json;charset=utf-8",
                    success:function(data){
                        if(data.success){
                            _this.addDeleData.delegationUserId=data.data.delegationUserId;
                            _this.addDeleData.delegationUserName=data.data.delegationUserName;
                            _this.addDeleData.delegationAccount=data.data.delegationAccount;
                            _this.addDeleData.createTime=data.data.createTime;
                            _this.delegationType=data.data.delegationType;
                            //根据返回值中PersonType属性判断用户类型，1表示本部人员，2表示供应商类型
                            if(data.data.personType==1){
                                _this.isLocal=true;
                                _this.legalPersonList=data.data.legalPersonList;//获取法人列表
                            }else if(data.data.personType==2){
                                _this.isLocal=false;
                                _this.deledUserList=data.data.userList;
                            }
                        }else{
                            _this.common.errorTip(data.errorMessage);
                        }
                    }
                })

            },
            // 选择法人 取id
            changeLegalPerson(){
                var _this = this;
                for(var i=0;i<_this.legalPersonList.length;i++){
                    if(_this.addDeleData.legalPersonName==_this.legalPersonList[i].id){
                        _this.addDeleData.legalPersonCode=_this.legalPersonList[i].legalPersonCode;//获取法人编码进行传参查询
                        _this.addDeleData.legalPersonId=_this.legalPersonList[i].id;//获取id查询供应商列表
                    }
                }
                _this.dropdownValue();//获取被委托人员下拉列表值
            },
            //获取被委托人员下拉列表值
            dropdownValue(){
                var _this=this;
                $.ajax({
                    type:'GET',
                    url:_this.metadata_service+"authorityDelegation/listUserByLegalPersonId?legalPersonId="+_this.addDeleData.legalPersonId,
                    cache:false,
                    dataType:'JSON',
                    contentType:"application/json;charset=utf-8",
                    success:function(data){
                        if(data.success){
                            _this.deledUserList = data.data;
                        }else{
                            _this.common.errorTip(data.errorMessage);
                        }
                    }
                })
            },
            //新建增加行项目
            addDeleSheet(){
                var _this=this;
                _this.deleNewList.push({type:"",commissionedUserId:"",commissionedAccount:""})
            },
            changeDeleAccount(index,row){
                var _this=this;
                for(var i=0;i<_this.deledUserList.length;i++){
                    if(row.commissionedUserId==_this.deledUserList[i].id){
                        row.commissionedAccount=_this.deledUserList[i].userName;
                        row.commissionedUserName=_this.deledUserList[i].personName;
                    }
                }
            },
            //验证行项目是否填写
            validIsDone(){
                var _this=this;
                var arr=_this.deleNewList;
                for(var i=0;i<arr.length;i++){
                    if(arr[i].type==""){
                        var err=_this.languageType=="zh"?'请选择委托单据':'Please select a commission document';
                        _this.common.errorTip(err);
                        return false;
                    }
                    if(arr[i].commissionedUserId==""){
                        //判断法人是否选择
                        if(_this.deledUserList.length!=0){
                            var err=_this.languageType=="zh"?'请选择被委托人员':'Please select the entrusted person';
                            _this.common.errorTip(err);
                            return false;
                        }else{
                            var err=_this.languageType=="zh"?'请选择法人':'Please select a legal person';
                            _this.common.errorTip(err);
                            return false;
                        }

                    }
                }
                return true;
            },
            //新增保存
            saveDeleSheet(formName){
                var _this=this;
                var validIsDid=_this.validIsDone();
                //验证表单
                _this.$refs[formName].validate((valid) => {
                    if(valid){
                        //验证行项目是否存在
                        if(_this.deleNewList.length!=0){
                            //验证行项目是否填写
                            if(validIsDid){
                                _this.save();//验证成功保存
                            }
                        }else{
                            var err=_this.languageType=="zh"?'请增加被委托人员':'Please increase the number of commissioned persons';
                            _this.common.errorTip(err);
                        }
                    }

                });
            },
            //保存
            save(){
                var _this=this;
                var tmp={
                    delegationUserId:_this.addDeleData.delegationUserId,//当前登录人ID
                    delegationUserName:_this.addDeleData.delegationUserName,//姓名
                    delegationAccount:_this.addDeleData.delegationAccount,//账户
                    startTime:_this.addDeleData.startTime,//委托开始日期
                    endTime:_this.addDeleData.endTime,//委托结束日期
                    reason:_this.addDeleData.reason,//委托原由
                    details:_this.deleNewList,//权限明细列表
                }
                if(_this.addDeleData.legalPersonId){
                    tmp.legalPersonId=_this.addDeleData.legalPersonId;//法人（只有本部人员传入)
                }
                _this.addSaveDisabled=true;
                $.ajax({
                    type: 'POST',
                    url: _this.metadata_service+"authorityDelegation/create",
                    cache: false,
                    data:JSON.stringify(tmp),
                    dataType:'JSON',
                    contentType: "application/json;charset=utf-8",
                    success: function (data) {
                        if(data.success){
                            _this.dialogForm1Visible=false;
                            var success=_this.languageType=="zh"?'保存成功':'Save successfully!';
                            _this.common.successTip(success);
                            _this.queryDeleSheet();
                        }else{
                            _this.common.errorTip(data.errorMessage);
                        }
                        _this.addSaveDisabled=false;
                    }
                });
            },
            //修改
            handleUpdateDele(index,row){
                var _this=this;
                _this.deleNewList=[];
                _this.dialogForm2Visible=true;
                _this.idParm=row.id;
                $.ajax({
                    type:'GET',
                    url:_this.metadata_service+"authorityDelegation/queryAuthorityDelegationById?id="+row.id,
                    cache:false,
                    dataType:'JSON',
                    contentType:"application/json;charset=utf-8",
                    success:function(data){
                        if(data.success){
                            _this.updateDeleData.delegationUserName=data.data.delegationUserName;
                            _this.updateDeleData.delegationAccount=data.data.delegationAccount;
                            _this.updateDeleData.createTime=data.data.createTime;
                            _this.updateDeleData.legalPersonName=data.data.legalPersonName;
                            _this.updateDeleData.startTime=data.data.startTime;
                            _this.updateDeleData.endTime=data.data.endTime;
                            _this.updateDeleData.reason=data.data.reason;
                            _this.deleNewList=data.data.details;//行项目
                        }else{
                            _this.common.errorTip(data.errorMessage);
                        }
                    }
                })
            },
            //修改保存
            saveUpdateDeleSheet(formName){
                var _this=this;
                //验证表单
                _this.$refs[formName].validate((valid) => {
                    if(valid) {
                        var tmp = {
                            id: _this.idParm,//当前登录人ID
                            startTime: _this.updateDeleData.startTime,//委托开始日期
                            endTime: _this.updateDeleData.endTime,//委托结束日期
                        }
                        _this.updateSaveDisabled=true;
                        $.ajax({
                            type: 'POST',
                            url: _this.metadata_service + "authorityDelegation/update",
                            cache: false,
                            data: JSON.stringify(tmp),
                            dataType: 'JSON',
                            contentType: "application/json;charset=utf-8",
                            success: function (data) {
                                if (data.success) {
                                    _this.dialogForm2Visible = false;
                                    var success=_this.languageType=="zh"?'修改成功！':'Update successfully!';
                                    _this.common.successTip(success);
                                    _this.queryDeleSheet();
                                } else {
                                    _this.common.errorTip(data.errorMessage);
                                }
                                _this.updateSaveDisabled=false;
                            }
                        });
                    }
                })

            },
            //失效
            handleLoseDele(index,row){
                var _this=this;
                _this.loseDeleDisabled=true;
                $.ajax({
                    type: 'GET',
                    url: _this.metadata_service+"authorityDelegation/disabledAuthorityDelegationById?id="+row.id,
                    cache: false,
                    dataType:'JSON',
                    contentType: "application/json;charset=utf-8",
                    success: function (data) {
                        if(data.success){
                            var success=_this.languageType=="zh"?'设置失效成功':'Setup failed successfully';
                            _this.common.successTip(success);
                            _this.queryDeleSheet();
                        }else{
                            _this.common.errorTip(data.errorMessage);
                        }
                        _this.loseDeleDisabled=false;
                    }
                });
            },
            //查看
            checkDele(index,row){
                var _this=this;
                _this.dialogForm3Visible=true;
                $.ajax({
                    type:'GET',
                    url:_this.metadata_service+"authorityDelegation/queryAuthorityDelegationById?id="+row.id,
                    cache:false,
                    dataType:'JSON',
                    contentType:"application/json;charset=utf-8",
                    success:function(data){
                        if(data.success){
                            _this.deleNewList=data.data.details;//行项目
                        }else{
                            _this.common.errorTip(data.errorMessage);
                        }
                    }
                })
            },
            //新增取消
            cancelDeleSheet(){
                var _this=this;
                _this.dialogForm1Visible=false;
                _this.addDeleData.delegationUserName="";
                _this.addDeleData.delegationAccount="";
                _this.addDeleData.createTime="";
                _this.addDeleData.startTime="";
                _this.addDeleData.endTime="";
                _this.addDeleData.reason="";
                _this.addDeleData.legalPersonName="";
            },
            //修改取消
            cancelUpdateDeleSheet(){
                var _this=this;
                _this.dialogForm2Visible=false;
            },
            //   分页
            handleSizeChange(val) {
                // console.log(`每页 ${val} 条`);
                var _this=this;
                _this.pageSize=val;
                _this.queryDeleSheet();

            },
            //点击页码分页查询点击事件
            handleCurrentChange(val) {
                // console.log(`当前页: ${val}`);
                var _this=this;
                _this.pageIndex=val;
                _this.queryDeleSheet();
            }
        }
    }
</script>



